package com.ruoyi.ai.controller;

import com.ruoyi.ai.domain.ChatMessage;
import com.ruoyi.ai.service.ChatService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/ai")
public class ChatController {

    private final ChatService chatService;
    @PostMapping("/chat")
    public Flux<String> chatStream(@RequestBody ChatMessage chatMessage) {
        log.info("chatMessage: {}", chatMessage);
        return chatService.chatStream(chatMessage.getPrompt());
    }
}
